<template>
   <div class="student">
     <h2>姓名:{{  name }}</h2>
     <h2>性别: {{ sex }}</h2>
     <button @click="sendName">发送名字给school</button>
   </div>
</template>

<script>
import pubsub from 'pubsub-js'
export default {
  name: "Student",
  data(){
    return {
       name: '张三',
       sex: '男'
    }
  },
  methods:{
    sendName(){
      pubsub.publish('hello',this.name)
      // this.$bus.$emit('SendToSchool',666)
    }
  }
}
</script>

<style scoped>
  .student{
    background: orange;
    padding: 5px;
    margin-bottom: 10px;
  }
</style>
